﻿var zonggai = {
	init : function(){
		var boss = this;
		
		boss.initLayout();
		boss.initEvent();
	},
	initLayout : function(){
		var boss = this;
		$(".tubiao-div, .xiangqing-div, .jingwuxinxitubiao-div").hide();
		boss.initText();
	},
	initEvent : function(){
		var boss = this;
		boss.clickEvent();
	},
	initText : function(){
		var boss = this;
		var htmlContent = "";
		var fullid = $("#xuanxiangka div[tag^='z'][selected]").last().attr("fullid");
		if(fullid == '0-1-'){
			boss.bajianjie();
		} else {
			if(fullid == "0-1-1163-"){
				$.ajax({
					dataType: 'text',
					async : false,
					url: burl + "/view/zonggai/xinle.jsp",
					success: function(d){
						htmlContent = d;
					}
				});
			} else if(fullid == "0-1-1164-"){
				$.ajax({
					dataType: 'text',
					async : false,
					url: burl + "/view/zonggai/fanshen.jsp",
					success: function(d){
						htmlContent = d;
					}
				});
			}
			$("#zonggai-text").html(htmlContent);
			$("#text_word tr[tag]").hide();
			$(".return").show();
			$("#text_word tr[tag='jieshao']").show();
		}
	},
	bajianjie : function(){
		var boss = this;
		$.ajax({
			dataType: 'text',
			async : false,
			url: burl + "/view/zonggai/baoan.jsp",
			success: function(d){
				htmlContent = d;
			}
		});
		$("#zonggai-text").html(htmlContent);
		$("#xuanxiangka div[tag^='z']").hide();
		$("#xuanxiangka div[tag='z1']").show();
		$(".liTab").hide();
		$(".return").hide();
		$("#text_word tr[tag]").hide();
		$("#text_word tr[tag='jieshao']").show();
		$("tr[tag='jieshao'] a").bind("mouseenter", function(){
			$(this).css("color", "#0000ff");
		});
		$("tr[tag='jieshao'] a").bind("mouseleave", function(){
			$(this).css("color", "#ff0000");
		});
		$("tr[tag='jieshao'] a").bind("click", function(){
			var tag = $(this).attr("tag");
			if(tag == "fanshen"){
				$.ajax({
					dataType: 'text',
					async : false,
					url: burl + "/view/zonggai/fanshen.jsp",
					success: function(d){
						htmlContent = d;
					}
				});
				$("div[tag='z2']").show();
				$("div[tag='z2']").attr("pid", "1164");
				$("div[tag='z2']").attr("selected", "selected");
				$("div[tag='z2']").attr("fullid", "0-1-1164-");
				$("div[tag='z2']").find(".mc").html("翻身派出所");
				$("div[tag='z2']").find(".mc").attr("pid", "1164");
			}else if(tag == "xinle"){
				$.ajax({
					dataType: 'text',
					async : false,
					url: burl + "/view/zonggai/xinle.jsp",
					success: function(d){
						htmlContent = d;
					}
				});
				$("div[tag='z2']").show();
				$("div[tag='z2']").attr("pid", "1163");
				$("div[tag='z2']").attr("selected", "selected");
				$("div[tag='z2']").attr("fullid", "0-1-1163-");
				$("div[tag='z2']").find(".mc").html("新乐派出所");
				$("div[tag='z2']").find(".mc").attr("pid", "1163");
			}
			$("#zonggai-text").html(htmlContent);
			$("#text_word tr[tag]").hide();
			$(".return").show();
			$("#text_word tr[tag='jieshao']").show();
			boss.clickEvent();
		});
	},
	clickEvent : function(){
		var boss = this;
		$("#text_word span[class='num']").bind("click", function(){
			var tag = $(this).parents("tr").attr("tag");
			var team = $(this).attr("team");
			var org = $("#xuanxiangka div[tag^='z'][selected]").last().find(".mc").html();
			$("#tab li").removeClass("selected");
			$("#main div[tag]").hide();
			$("li[tag='grid']").addClass("selected");
			main.initGridSize();
			main.loadJsp("grid");
			$("#main div[tag='grid']").show();
			$("#menu_tab div[tag]").hide();
			$("#con-tab-menu li").removeClass("menu-tab-selected");
			$("#con-tab-menu li[tag='" + tag + "']").addClass("menu-tab-selected");
			$("div[tag='" + tag + "']").show();
			if(tag == "jingli"){
				if(team == "all"){
					grid.showPolicePositionGrid("", "", grid.getFullId(), org + "总人数列表");
					$("#subgrid_count").hide();
					$("#grid_list").show();
				} else if(team == "0"){
					grid.showPolicePeopleGrid(org + "民警");
					$("#subgrid_count").hide();
				}else{
					grid.showSubPolicePositionCountDB(team);
					$("#subgrid_count").show();
					$("#grid_list").hide();
				}
				$("#Count-grid").hide();
				$("#closeTable").attr("selected", "selected");
				$("#closeTable img").attr("src", burl + "/images/grid-images/openBtn.png");
			}else if(tag == "jingqing"){
				grid.showAlertGrid();
			}else if(tag == "jingwuxinxi"){
				grid.showAllApartmentCountDB();
			}
		});
		$("#text_word span[class='num']").bind("mouseenter", function(){
			$(this).css("color", "#0000ff");
		});
		$("#text_word span[class='num']").bind("mouseleave", function(){
			$(this).css("color", "#ff0000");
		});
		$("#liTab li").bind("click", function(){
			$(".liTab li").removeClass("selected");
			$(this).addClass("selected");
			$("#text_word tr[tag]").hide();
			var tag = $(this).attr("tag");
			$("#text_word tr[tag='" + tag + "']").show();
			$(".showmap").bind("mouseenter", function(){
				$(this).css("color", "#0000ff");
			});
			$(".showmap").bind("mouseleave", function(){
				$(this).css("color", "#ff0000");
			});
			$("#text_word tr[tag='" + tag + "'] a").bind("click", function(){
				var fullid = $("#xuanxiangka div[tag^='z'][selected]").last().attr("fullid");
				window.open(burl + '/view/zonggai/tubiao.jsp?tag=' + tag + "&fullid=" + fullid, "", "height=608,width=1056,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
			});
		});
		$(".zonggai-mc").bind("click", function(){
			$("#text_word tr[tag]").hide();
			$("#text_word tr[tag='jieshao']").show();
			$(".liTab li").removeClass("selected");
		});
		$(".return img").bind("mouseenter", function(){
			$(this).attr("src", burl + "/images/jiantou1.png");
		});
		$(".return img").bind("mouseleave", function(){
			$(this).attr("src", burl + "/images/jiantou.png");
		});
		$(".return img").bind("click", function(){
			$("#zonggai-text").empty();
			boss.bajianjie();
		});
	}
	
};